<?php
/*
 * 	Manhali - Free Course Management System
 *	chaps.php
 *	2011-01-27 12:36
 * 	Author: El Haddioui Ismail <ismail.elhaddioui@gmail.com>
 * 	Copyright (C) 2009-2011  El Haddioui Ismail. All rights reserved
 * 	License : GNU/GPL v3

This file is part of Manhali

Manhali is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Manhali is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Manhali.  If not, see <http://www.gnu.org/licenses/>.

*/

defined("access_const") or die( 'Restricted access' );

$chap = intval($_GET['chapter']);
	
$selectchap = mysql_query("select * from `" . $tblprefix . "chapitres` where id_chapitre = $chap and publie_chapitre = '1';");
if (mysql_num_rows($selectchap) == 1) {
	
 $chapitre = mysql_fetch_row($selectchap);

 $id_chapitre = $chapitre[0];
 $id_partie = $chapitre[1];
 $ordre_chapitre = $chapitre[6];

 // tutoriel infos
 $select_tuto_id= mysql_query("select id_tutoriel from `" . $tblprefix . "parties` where id_partie = $id_partie and publie_partie = '1';");
 if (mysql_num_rows($select_tuto_id) == 1) {
	$id_tutoriel = mysql_result($select_tuto_id,0,0);
	
	$select_tuto = mysql_query("select * from `" . $tblprefix . "tutoriels` where id_tutoriel = $id_tutoriel and publie_tutoriel = '2';");
	if (mysql_num_rows($select_tuto) == 1) {
	 $tutoriel = mysql_fetch_row($select_tuto);
	
	 $id_user = $tutoriel[1];
	 $titre_tutoriel = $tutoriel[2];
	 $licence_tutoriel = $tutoriel[6];
		
	// acces tutoriel
	$acces = $tutoriel[13];
	$acces_valide = 0;
	if ($acces == "*")
		$acces_valide = 1;
	else if ($acces == "0" && isset($_SESSION['connect']["log"]) && !empty($_SESSION['connect']["log"]))
		$acces_valide = 1;
	else if (!empty($_SESSION['connect']["log"]) && $_SESSION['connect']["log"] == 1)
			$acces_valide = 1;
	else if (!empty($_SESSION['connect']["log"]) && $_SESSION['connect']["log"] == 2){
		$select_classe = mysql_query("select id_classe from `" . $tblprefix . "apprenants` where id_apprenant = $id_user_session;");
    if (mysql_num_rows($select_classe) == 1){
			$id_classe = mysql_result($select_classe,0);
			$tab_classes = explode("-",$acces);
			if (in_array($id_classe,$tab_classes))
				$acces_valide = 1;
		}
	}
	if ($acces_valide == 1){

// chapitre infos
		$titre_chapitre = html_ent($chapitre[2]);
		$objectifs_chapitre = view_bbcode(trim($chapitre[3]));

		$nombre_lectures = $chapitre[4] + 1;
		$date_creation_chapitre = $chapitre[7];
		$date_modification_chapitre = $chapitre[8];

// select auteur name and email
	$selectauteur = mysql_query("select identifiant_user, email_user, photo_profil from `" . $tblprefix . "users` where id_user = $id_user;");
	if (mysql_num_rows($selectauteur) == 1) {
		
		$auteur = mysql_result($selectauteur,0,0);
		if (!empty($auteur))
			$auteur = html_ent($auteur);
		else $auteur = inconnu;

		$mail_auteur = mysql_result($selectauteur,0,1);
		if (!empty($mail_auteur)){
			$mail_auteur = html_ent($mail_auteur);
			$mail_auteur = mail_antispam($mail_auteur,0);
		} else $mail_auteur = "";

		$photo_profil = mysql_result($selectauteur,0,2);
	} else {
		$auteur = inconnu;
		$mail_auteur = "";
		$photo_profil = "";
	}

// incrementer le nombre de lectures
		$update_nbr_lectures = mysql_query("update `" . $tblprefix . "chapitres` set nombre_lectures = $nombre_lectures where id_chapitre = $id_chapitre;");

// ordre partie
		$select_partie_ordre = mysql_query("select ordre_partie from `" . $tblprefix . "parties` where id_partie = $id_partie;");
		$ordre_partie = mysql_result($select_partie_ordre,0);
// chapitre precedent
		$selectprecedent = mysql_query("select id_chapitre from `" . $tblprefix . "chapitres` where id_partie = $id_partie and ordre_chapitre < $ordre_chapitre and publie_chapitre = '1' order by ordre_chapitre desc;");
		if (mysql_num_rows($selectprecedent) > 0)
			$chap_precedent = mysql_result($selectprecedent,0);
		else {
			$select_partie_precedent = mysql_query("select id_partie from `" . $tblprefix . "parties` where id_tutoriel = $id_tutoriel and ordre_partie < $ordre_partie and publie_partie = '1' order by ordre_partie desc;");
			if (mysql_num_rows($select_partie_precedent) > 0) {
				$partie_precedent = mysql_result($select_partie_precedent,0);
				$selectprecedent2 = mysql_query("select id_chapitre from `" . $tblprefix . "chapitres` where id_partie = $partie_precedent and publie_chapitre = '1' order by ordre_chapitre desc;");
				if (mysql_num_rows($selectprecedent2) > 0)
					$chap_precedent = mysql_result($selectprecedent2,0);
				else $chap_precedent = 0;
			}
			else $chap_precedent = 0;
		}

// chapitre suivant
		$selectsuivant = mysql_query("select id_chapitre from `" . $tblprefix . "chapitres` where id_partie = $id_partie and ordre_chapitre > $ordre_chapitre and publie_chapitre = '1' order by ordre_chapitre;");
		if (mysql_num_rows($selectsuivant) > 0)
			$chap_suivant = mysql_result($selectsuivant,0);
		else {
			$select_partie_suivant = mysql_query("select id_partie from `" . $tblprefix . "parties` where id_tutoriel = $id_tutoriel and ordre_partie > $ordre_partie and publie_partie = '1' order by ordre_partie;");
			if (mysql_num_rows($select_partie_suivant) > 0) {
				$partie_suivant = mysql_result($select_partie_suivant,0);
				$selectsuivant2 = mysql_query("select id_chapitre from `" . $tblprefix . "chapitres` where id_partie = $partie_suivant and publie_chapitre = '1' order by ordre_chapitre;");
				if (mysql_num_rows($selectsuivant2) > 0)
					$chap_suivant = mysql_result($selectsuivant2,0);
				else $chap_suivant = 0;
			}
			else $chap_suivant = 0;
		}

// reponses qcm
	$select_reponses_qcm = mysql_query("select sum(total_essais), sum(total_reponses_correctes) from `" . $tblprefix . "qcm` where id_chapitre = $id_chapitre;");
	$total_essais = mysql_result($select_reponses_qcm,0,0);
	$total_reponses_correctes = mysql_result($select_reponses_qcm,0,1);

//affichage suivant precedent

		echo "<table width=\"50%\" align=\"center\" style=\"border: 1px solid #000000;\"><tr><td align=\"center\" width=\"50%\" style=\"border: 1px solid #000000;\"><b>";

		if ($chap_precedent > 0)
			echo "<table border=\"0\"><tr><td><a href=\"?chapter=".$chap_precedent."\"><img border=\"0\" src=\"images/others/precedent.png\" width=\"32\" height=\"32\" /></a></td><td><a href=\"?chapter=".$chap_precedent."\"><b>".chap_precedent."</b></a></td></tr></table>";
		else echo "<table border=\"0\"><tr><td><img border=\"0\" src=\"images/others/precedent2.png\" width=\"32\" height=\"32\" /></td><td><b>".chap_precedent."</b></td></tr></table>";

		echo "</b></td><td align=\"center\" width=\"50%\" style=\"border: 1px solid #000000;\"><b>";
		
		if ($chap_suivant > 0)
			echo "<table border=\"0\"><tr><td><a href=\"?chapter=".$chap_suivant."\"><b>".chap_suivant."</b></a></td><td><a href=\"?chapter=".$chap_suivant."\"><img border=\"0\" src=\"images/others/suivant.png\" width=\"32\" height=\"32\" /></a></td></tr></table>";
		else echo "<table border=\"0\"><tr><td><b>".chap_suivant."</b></td><td><img border=\"0\" src=\"images/others/suivant2.png\" width=\"32\" height=\"32\" /></td></tr></table>";
		
		echo "</b></td></tr></table>";

// affichage chapitre

		echo "<br /><table width=\"100%\" align=\"center\" cellpadding=\"5\" cellspacing=\"5\">";
		echo "<tr><td colspan=\"2\" align=\"center\" width=\"100%\"><div id=\"titre\">".$titre_chapitre."</div><br /></td></tr>\n";	
		echo "<tr><td width=\"60%\" valign=\"top\">";
	
		if (!empty($objectifs_chapitre)) {
			echo "<table width=\"95%\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\"><tr><td><div id=\"objectifs\">".objectifs_chapitre."</div>";
			echo "<div id=\"normal\">".$objectifs_chapitre."</div></td></tr></table>\n";
		}

// un bloc
		$selectunbloc = mysql_query("select * from `" . $tblprefix . "blocs` where id_chapitre = $id_chapitre and publie_bloc = '1' order by ordre_bloc;");
		if (mysql_num_rows($selectunbloc)> 0) {
			echo "<ul>";
			$unbloc = mysql_fetch_row($selectunbloc);
			$id_unbloc = $unbloc[0];
			$titre_unbloc = html_ent($unbloc[2]);
			$contenu_unbloc = view_bbcode($unbloc[3]);

			echo "<br /><li class=\"bloc\"><a class=\"bloc\" name=\"".$id_unbloc."\" href=\"?chapter=".$id_chapitre."#".$id_unbloc."\">".$titre_unbloc."</a></li>\n";
			echo "<br /><br /><div id=\"normal\">".$contenu_unbloc."</div>\n";
			echo "</ul>";
		} else $id_unbloc = 0;
		
// affichage infos

		echo "</td><td width=\"40%\" valign=\"top\"><table width=\"100%\" border=\"0\" class=\"infos\" cellpadding=\"0\" cellspacing=\"0\">";
		echo "<tr><td><br /><div id=\"tuto_infos\">".chap_infos."</div><br /></td></tr>\n";
		echo "<tr><td align=\"left\"><ul><li><b>".tutoriel." :</b> <a class=\"bloc\" href=\"?tutorial=".$id_tutoriel."\">".html_ent($titre_tutoriel)."</a></li></ul></td></tr>\n";
		echo "<tr><td align=\"center\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
		echo "<tr><td rowspan=\"3\" align=\"right\">";
		if (!empty($photo_profil))
			echo "<img border=\"0\" src=\"docs/".$photo_profil."\" alt=\"".$auteur."\" width=\"100\" height=\"100\" />";
			
		if ($afficher_profil == 1)
			echo "</td><td colspan=\"2\" align=\"left\"><ul><li><b>".auteur." <a href=\"?profiles=".$id_user."\" title=\"".user_profile."\">".$auteur."</a></b></li></ul></td></tr>\n";
		else
			echo "</td><td colspan=\"2\" align=\"left\"><ul><li><b>".auteur." ".$auteur."</b></li></ul></td></tr>\n";

		echo "<tr><td colspan=\"2\" align=\"left\"><ul><li><b>".email." : ".$mail_auteur."</b></li></ul></td></tr>\n";
		echo "<tr><td align=\"left\"><ul><li><b>".licence."</b></li></td><td align=\"left\"><a target=\"_blank\" title=\"".licence_const($licence_tutoriel)."\" href=\"http://creativecommons.org/licenses/".$licence_tutoriel."/3.0/\"><img src=\"images/licenses/".$licence_tutoriel.".png\" border=\"0\" alt=\"".licence_const($licence_tutoriel)."\" /></a></ul></td></tr>\n";
		echo "</table></td></tr>";

	// ********* rating
	$nombre_votes_chapitre = $chapitre[9];
	$rating_chapitre = $chapitre[10];
	if ($nombre_votes_chapitre > 0 && $rating_chapitre > 0 && ctype_digit($nombre_votes_chapitre) && ctype_digit($rating_chapitre))
		$rating_chap = round($rating_chapitre / $nombre_votes_chapitre);
	else $rating_chap = 3;
	if ($rating_chap < 1 || $rating_chap > 6)
		$rating_chap = 3;
	$can_rate = 0;
if (isset($_SESSION['connect']["log"]) && !empty($_SESSION['connect']["log"])){
	if ($_SESSION['connect']["log"] == 1){
		$select_chaps_vote = mysql_query("select chaps_vote from `" . $tblprefix . "users` where id_user = $id_user_session;");
		if (mysql_num_rows($select_chaps_vote) == 1){
			$chaps_vote = mysql_result($select_chaps_vote,0);
			$tab_chaps_vote = explode("-",$chaps_vote);
			if (!in_array($id_chapitre,$tab_chaps_vote) && $id_user != $id_user_session){
				$can_rate = 1;
				if (!empty($_GET['rating']) && ctype_digit($_GET['rating']) && $_GET['rating'] > 0 && $_GET['rating'] < 7){
					$new_nombre_votes_chapitre = $nombre_votes_chapitre+1;
					$new_rating_chapitre = $rating_chapitre + $_GET['rating'];
					$update_rating = mysql_query("update `" . $tblprefix . "chapitres` set nombre_votes_chapitre = $new_nombre_votes_chapitre, rating_chapitre = $new_rating_chapitre where id_chapitre = $id_chapitre;");
					$chaps_vote .= $id_chapitre."-";
					$update_chaps_vote = mysql_query("update `" . $tblprefix . "users` set chaps_vote = '$chaps_vote' where id_user = $id_user_session;");
					echo "<script type=\"text/javascript\">window.location.href = \"?chapter=".$id_chapitre."\";</script>";
				}
			}
		}
	}
	else if ($_SESSION['connect']["log"] == 2){
		$select_chaps_vote = mysql_query("select chaps_vote from `" . $tblprefix . "apprenants` where id_apprenant = $id_user_session;");
		if (mysql_num_rows($select_chaps_vote) == 1){
			$chaps_vote = mysql_result($select_chaps_vote,0);
			$tab_chaps_vote = explode("-",$chaps_vote);
			if (!in_array($id_chapitre,$tab_chaps_vote)){
				$can_rate = 1;
				if (!empty($_GET['rating']) && ctype_digit($_GET['rating']) && $_GET['rating'] > 0 && $_GET['rating'] < 7){
					$new_nombre_votes_chapitre = $nombre_votes_chapitre+1;
					$new_rating_chapitre = $rating_chapitre + $_GET['rating'];
					$update_rating = mysql_query("update `" . $tblprefix . "chapitres` set nombre_votes_chapitre = $new_nombre_votes_chapitre, rating_chapitre = $new_rating_chapitre where id_chapitre = $id_chapitre;");
					$chaps_vote .= $id_chapitre."-";
					$update_chaps_vote = mysql_query("update `" . $tblprefix . "apprenants` set chaps_vote = '$chaps_vote' where id_apprenant = $id_user_session;");
					echo "<script type=\"text/javascript\">window.location.href = \"?chapter=".$id_chapitre."\";</script>";
				}
			}
		}
	}
}
	if ($can_rate == 1){
		echo "<script language=\"javascript\" type=\"text/javascript\" src=\"styles/rating.js\"></script>";
		echo "<tr><td align=\"left\"><ul><li><div onmouseout=\"old_rating(this, event, ".$rating_chap.");\" onmouseover=\"init_stars();\"><b>".rating." : </b>";
	}
	else
		echo "<tr><td align=\"left\"><ul><li><div><b>".rating." : </b>";
	for($i=1;$i<=6;$i++){
		if ($i <= $rating_chap)
			$img_rating = "star_over.gif";
		else
			$img_rating = "star_out.gif";
		echo "<img border=\"0\" id=\"Star".$i."\" src=\"images/others/".$img_rating."\" alt=\"".$i."/6\" title=\"".$i."/6\" width=\"25\" height=\"23\" />";
	}
	echo " <b>(".$nombre_votes_chapitre." ".votes." : ".$rating_chap."/6)</b></div></li></ul></td></tr>\n";
	if ($can_rate == 1)
		echo "<script type=\"text/javascript\">NotationSystem('?chapter=".$id_chapitre."');</script>";
	//*********

		echo "<tr><td align=\"left\"><ul><li><b>".cree." ".date("d/m/Y - H:i:s",$date_creation_chapitre)."</b></li></ul></td></tr>\n";
		echo "<tr><td align=\"left\"><ul><li><b>".modifie." ".date("d/m/Y - H:i:s",$date_modification_chapitre)."</b></li></ul></td></tr>\n";
		echo "<tr><td align=\"left\"><ul><li><b>".lu." ".$nombre_lectures." ".fois."</b></li></ul></td></tr>\n";
		
		if ($total_essais != 0 && $total_reponses_correctes <= $total_essais){
			$reponses_tuto = round(100 * $total_reponses_correctes / $total_essais,2);
			echo "<tr><td align=\"left\"><ul><li><b>".reponses_qcm." ".$reponses_tuto." %</b></li></ul></td></tr>\n";
		}
		echo "</table></td></tr><tr><td colspan=\"2\" width=\"100%\">";

// blocs		
		$selectblocs = mysql_query("select * from `" . $tblprefix . "blocs` where id_chapitre = $id_chapitre and id_bloc != $id_unbloc and publie_bloc = '1' order by ordre_bloc;");
		if (mysql_num_rows($selectblocs)> 0) {
			echo "<ul>";
			while($bloc = mysql_fetch_row($selectblocs)) {
				$id_bloc = $bloc[0];

				$titre_bloc = html_ent($bloc[2]);
				$contenu_bloc = view_bbcode($bloc[3]);

				echo "<li class=\"bloc\"><a class=\"bloc\" name=\"".$id_bloc."\" href=\"?chapter=".$id_chapitre."#".$id_bloc."\">".$titre_bloc."</a></li>\n";
				echo "<br /><br /><div id=\"normal\">".$contenu_bloc."</div><br />\n";
			}
			echo "</ul>";
		}
		echo "</td></tr>";

 // Traitement QCM

	echo "<tr><td colspan=\"2\" width=\"100%\"><hr /><hr /><br />\n";
	
	if (isset($_POST['qcm'])){
		
		echo "<div id=\"titre\"><a name=\"qcm\">".resultats_qcm."</a></div><br />\n";

		$select_qcm = mysql_query("select * from `" . $tblprefix . "qcm` where publie_qcm = '1' and id_chapitre = $id_chapitre order by ordre_qcm;");
		if (mysql_num_rows($select_qcm) > 0) {
			
			$total_questions = mysql_num_rows($select_qcm);
			$mes_bonnes_reponses = 0;
			
			echo "<table width=\"100%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"50%\" valign=\"top\">";
			
			while($qcm = mysql_fetch_row($select_qcm)){
				$id_qcm = $qcm[0];
				$question_qcm = view_bbcode($qcm[2]);
				$reponse_correcte = $qcm[9];
				
				$total_essais = $qcm[10];
				$total_reponses_correctes = $qcm[11];
				
				// repondu
				if(isset($_POST[$id_qcm]) && ctype_digit($_POST[$id_qcm])) {

					$total_essais += 1;

					if ($reponse_correcte == $_POST[$id_qcm]) {
						echo "<img border=\"0\" src=\"images/others/valide.png\" width=\"32\" height=\"32\" />";
						$total_reponses_correctes += 1;
						$mes_bonnes_reponses += 1;
					} else echo "<img border=\"0\" src=\"images/others/delete.png\" width=\"32\" height=\"32\" />";
						
					$update_qcm = mysql_query("update `" . $tblprefix . "qcm` set total_essais = $total_essais, total_reponses_correctes = $total_reponses_correctes where id_qcm = $id_qcm;");

					echo " ".$question_qcm;

					echo "<ul>";
					for ($i=1;$i<7;$i++){
						if (!empty($qcm[$i+2])){
							echo "<li>";

							if ($reponse_correcte == $i)
								echo "<font color=\"green\">";

							if ($_POST[$id_qcm] == $i && $_POST[$id_qcm] != $reponse_correcte)
								echo "<font color=\"red\">";

							echo "<b>".html_ent($qcm[$i+2])."</b>";

							if ($reponse_correcte == $i)
								echo "</font>";
							
							if ($_POST[$id_qcm] == $i && $_POST[$id_qcm] != $reponse_correcte)
								echo "</font>";
							
							echo "</li><br />";
						}
					}
					echo "</ul>";
				}
				// non repondu
				else {
					
					echo "<img border=\"0\" src=\"images/others/delete.png\" width=\"32\" height=\"32\" />";
					echo " ".$question_qcm;

					echo "<ul>";
					for ($i=1;$i<7;$i++){
						if (!empty($qcm[$i+2])){
							echo "<li>";
							
							if ($reponse_correcte == $i)
								echo "<font color=\"green\">";
		
							echo "<b>".html_ent($qcm[$i+2])."</b>";
							
							if ($reponse_correcte == $i)
								echo "</font>";

							echo "</li><br />";
						}
					}
					echo "</ul>";
				}
			}
			
			echo "</td><td width=\"50%\" valign=\"top\" align=\"right\"><table width=\"100%\" border=\"0\" class=\"infos\" cellpadding=\"5\" cellspacing=\"5\">";
			echo "<tr><td><br /><div id=\"tuto_infos\">".pourcentage_reponses."</div><br /></td></tr>";
			
			$select_question_qcm = mysql_query("select question_qcm, total_essais, total_reponses_correctes from `" . $tblprefix . "qcm` where publie_qcm = '1' and id_chapitre = $id_chapitre order by ordre_qcm;");
			if (mysql_num_rows($select_question_qcm) > 0) {
				while($myqcm = mysql_fetch_row($select_question_qcm)){
					$question_qcm = view_bbcode($myqcm[0]);
					$question_qcm = no_br($question_qcm);
					$question_qcm = readmore($question_qcm,50);
					
					$total_essais = $myqcm[1];
					$total_reponses_correctes = $myqcm[2];
					
					if ($total_essais != 0 && $total_reponses_correctes <= $total_essais)
						$statistiques = round(100*$total_reponses_correctes/$total_essais,2);
					else $statistiques = 0;
					
					echo "<tr><td align=\"left\"><img border=\"0\" src=\"images/others/question.png\" width=\"20\" height=\"20\" /> ".$question_qcm." : <b>".$statistiques." %</b></td></tr>\n";
				}
			}
			echo "</table></td></tr><tr><td colspan=\"2\" align=\"center\" width=\"100%\">";
			$note = round(20*$mes_bonnes_reponses/$total_questions,2);
			echo "<h2>".votre_note." ".$note." / 20</h2>";
			echo "</td></tr></table>";
			
		} else accueil();
	}
	else {

		$selectqcm = mysql_query("select * from `" . $tblprefix . "qcm` where id_chapitre = $id_chapitre and publie_qcm = '1' order by ordre_qcm;");
		if (mysql_num_rows($selectqcm)> 0) {

			echo "<div id=\"titre\"><a name=\"qcm\">";

			$selnomqcm = mysql_query("select titre_composant from `" . $tblprefix . "composants` where nom_composant = 'self_evaluation';");
			if (mysql_num_rows($selnomqcm) == 1) {
				$titre_qcm = mysql_result($selnomqcm,0);
				if (!empty($titre_qcm))
					echo $titre_qcm;
				else echo qcm;
			} else echo qcm;
			
			echo "\n</a></div><form method=\"POST\" action=\"?chapter=".$id_chapitre."#qcm\">";
			while($qcm = mysql_fetch_row($selectqcm)) {
				$id_qcm = $qcm[0];
				$question_qcm = view_bbcode($qcm[2]);
				echo "\n<p><img border=\"0\" src=\"images/others/question.png\" width=\"20\" height=\"20\" /> ".$question_qcm."<br /></p>";
				for ($i=1;$i<7;$i++){
					if (!empty($qcm[$i+2])){
						echo "\n<input name=\"".$id_qcm."\" type=\"radio\" value=\"".$i."\">";
						echo "<b>".html_ent($qcm[$i+2])."</b><br /><br />";
					}
				}
				echo "<hr />";
			}
			echo "<input type=\"hidden\" name=\"qcm\" value=\"ok\">";
			echo "<center><input type=\"submit\" class=\"button\" value=\"" .btncorriger. "\"></center></form><br />";
		}
	}
	echo "</td></tr></table>";

//affichage suivant precedent

		echo "<table width=\"50%\" align=\"center\" style=\"border: 1px solid #000000;\"><tr><td align=\"center\" width=\"50%\" style=\"border: 1px solid #000000;\"><b>";

		if ($chap_precedent > 0)
			echo "<table border=\"0\"><tr><td><a href=\"?chapter=".$chap_precedent."\"><img border=\"0\" src=\"images/others/precedent.png\" width=\"32\" height=\"32\" /></a></td><td><a href=\"?chapter=".$chap_precedent."\"><b>".chap_precedent."</b></a></td></tr></table>";
		else echo "<table border=\"0\"><tr><td><img border=\"0\" src=\"images/others/precedent2.png\" width=\"32\" height=\"32\" /></td><td><b>".chap_precedent."</b></td></tr></table>";

		echo "</b></td><td align=\"center\" width=\"50%\" style=\"border: 1px solid #000000;\"><b>";
		
		if ($chap_suivant > 0)
			echo "<table border=\"0\"><tr><td><a href=\"?chapter=".$chap_suivant."\"><b>".chap_suivant."</b></a></td><td><a href=\"?chapter=".$chap_suivant."\"><img border=\"0\" src=\"images/others/suivant.png\" width=\"32\" height=\"32\" /></a></td></tr></table>";
		else echo "<table border=\"0\"><tr><td><b>".chap_suivant."</b></td><td><img border=\"0\" src=\"images/others/suivant2.png\" width=\"32\" height=\"32\" /></td></tr></table>";
		
		echo "</b></td></tr></table><br />";
	 } else echo "<h2><center><font color=\"red\">".no_access_permission."</font></center></h2>";
	} else accueil();
 } else accueil();
} else accueil();
 
?>